package com.yuexinduo.education.fragment;

import android.content.Intent;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.yuexinduo.education.R;
import com.yuexinduo.education.adapter.HomeSchoolAdapter;
import com.yuexinduo.education.adapter.HomeStudyAdapter;
import com.yuexinduo.education.adapter.HomeSubjectsAdapter;
import com.yuexinduo.baselibrary.base.BaseMvpFragment;
import com.yuexinduo.education.bean.HomeSchoolBean;
import com.yuexinduo.education.bean.HomeStudyBean;
import com.yuexinduo.education.bean.HomeSubjectsBean;
import com.yuexinduo.education.ui.MemberBenefitActivity;
import com.yuexinduo.education.ui.SeekTeacherActivity;
import com.yuexinduo.education.ui.TeacherBankActivity;
import com.yuexinduo.education.view.MyGridView;

import java.util.ArrayList;
import java.util.List;

public class HomeFragment extends BaseMvpFragment implements View.OnClickListener {
    private TextView homeAddressCity;
    private ImageView homeMine;
    private ImageView homeImg;
    private MyGridView homeStudyType;
    private TextView homeTeacher;
    private TextView homeTeacherAll;
    private TextView homeStudent;
    private TextView homeStudentAll;
    private MyGridView homeSubjects;
    private MyGridView homeSchool;

    private ArrayList<HomeStudyBean> studyList= new ArrayList();
    private List<HomeSubjectsBean> subjectsList = new ArrayList<>();
    private List<HomeSchoolBean> schoolList = new ArrayList<>();

    @Override
    public boolean isLazyLoad() {
        return false;
    }

    @Override
    protected int bindLayout() {
        return R.layout.fragment_home;
    }

    @Override
    protected void initView() {

        homeAddressCity = (TextView) containerView.findViewById(R.id.home_address_city);
        homeMine = (ImageView) containerView.findViewById(R.id.home_mine);
        homeImg = (ImageView) containerView.findViewById(R.id.home_img);
        homeStudyType = (MyGridView) containerView.findViewById(R.id.home_study_type);
        homeTeacher = (TextView) containerView.findViewById(R.id.home_teacher);
        homeTeacherAll = (TextView) containerView.findViewById(R.id.home_teacher_all);
        homeStudent = (TextView) containerView.findViewById(R.id.home_student);
        homeStudentAll = (TextView) containerView.findViewById(R.id.home_student_all);
        homeSubjects = (MyGridView) containerView.findViewById(R.id.home_subjects);
        homeSchool = (MyGridView) containerView.findViewById(R.id.home_school);

        homeAddressCity.setOnClickListener(this);
        homeImg.setOnClickListener(this);
        homeTeacher.setOnClickListener(this);
        homeTeacherAll.setOnClickListener(this);
        homeStudent.setOnClickListener(this);
        homeStudentAll.setOnClickListener(this);
    }

    @Override
    protected void initData() {
        studyList.add(new HomeStudyBean(1,"学前小学"));
        studyList.add(new HomeStudyBean(2,"初中高中"));
        studyList.add(new HomeStudyBean(3,"大学考试"));
        studyList.add(new HomeStudyBean(4,"艺术体育"));
        studyList.add(new HomeStudyBean(5,"出国留学"));
        studyList.add(new HomeStudyBean(6,"生活兴趣"));
        studyList.add(new HomeStudyBean(7,"语言培训"));
        studyList.add(new HomeStudyBean(8,"更多科目"));

        HomeStudyAdapter homeStudyAdapter = new HomeStudyAdapter(getActivity(), studyList);
        homeStudyType.setAdapter(homeStudyAdapter);

        subjectsList.add(new HomeSubjectsBean(1,"数学"));
        subjectsList.add(new HomeSubjectsBean(2,"语文"));
        subjectsList.add(new HomeSubjectsBean(3,"英语"));
        subjectsList.add(new HomeSubjectsBean(4,"物理"));
        subjectsList.add(new HomeSubjectsBean(5,"化学"));

        HomeSubjectsAdapter homeSubjectsAdapter = new HomeSubjectsAdapter(getActivity(), subjectsList);
        homeSubjects.setAdapter(homeSubjectsAdapter);

        schoolList.add(new HomeSchoolBean(1,"清华"));
        schoolList.add(new HomeSchoolBean(2,"北大"));
        schoolList.add(new HomeSchoolBean(3,"复旦"));
        schoolList.add(new HomeSchoolBean(4,"南开"));
        schoolList.add(new HomeSchoolBean(5,"武汉"));

        HomeSchoolAdapter homeSchoolAdapter = new HomeSchoolAdapter(getActivity(), schoolList);
        homeSchool.setAdapter(homeSchoolAdapter);


    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.home_address_city:
                break;
            case R.id.home_img:
                break;
            case R.id.home_student:
            case R.id.home_student_all:
                startActivity(new Intent(getActivity(), MemberBenefitActivity.class));
                break;
            case R.id.home_teacher_all:
                startActivity(new Intent(getActivity(), TeacherBankActivity.class));
                break;
            case R.id.home_teacher:
                startActivity(new Intent(getActivity(), SeekTeacherActivity.class));
                break;
        }
    }
}
